package sh.wn36.vehiclemanage.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import sh.wn36.vehiclemanage.entity.Driver;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import sh.wn36.vehiclemanage.vo.driverInfo;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xk
 * @since 2021-04-26
 */
@Service
public interface DriverMapper extends BaseMapper<Driver> {


    @Select("select driver.*,d1.text,d2.text type\n" +
            "from driver\n" +
            "LEFT JOIN dictionary d1  on d1.id=driver.dept_id\n" +
            "LEFT JOIN dictionary d2 on d2.id = driver.driver_type ${ew.customSqlSegment}")
    IPage<driverInfo> selectPage(Page page,@Param(Constants.WRAPPER) Wrapper<driverInfo> queryWrapper);

    @Select("select driver.*,d1.text,d2.text type\n" +
            "from driver\n" +
            "LEFT JOIN dictionary d1  on d1.id=driver.dept_id\n" +
            "LEFT JOIN dictionary d2 on d2.id = driver.driver_type ")
    IPage<driverInfo> listPage(Page<driverInfo> page);

    @Select("SELECT * FROM driver WHERE isdisable = 0")
    List<Driver> getDriver1();
}
